<div class="row">
<style>
img{width:50px;border:none;}
.my_red{color:red;}
.my_green{color:green;}
.Tselect select{border:1px solid #CCCCCC;border-radius:5px;padding-left:5px;height: 30px;width: 100px;}
.Tselect select option{padding-left: 5px;}
.Tsearch input{height: 30px;border-radius: 5px;border: 1px solid #CCCCCC;padding-left: 5px;line-height: 30px;}
.source_type{cursor: pointer;}
.source_type:hover{background: #DDDDDD;color: red;}
.source_red{color: red;}
.source_green{color: green;}
.source_common{border: 1px solid #ccc;font-weight: bold;padding: 3px;border-radius: 3px;}
</style>
<!-- 表示一个成功的或积极的动作 -->
<div class="col-xs-6">
<div class="btn-group">	
	<!--<a href="{:U('User/index')}"><button type="button" class="btn btn-primary active">达人管理</button></a>-->
	<button type="button" class="btn btn-primary active" data-url="{:U('Ivdisk/index')}">资源列表</button>
	<button type="button" class="btn btn-primary"  data-toggle="modal" data-target="#myModal">收录资源</button>
	<button type="button" class="btn btn-primary"  data-toggle="modal" data-target="#postIvdisk">新浪微盘发帖</button>
</div>
</div>
<section class="col-xs-3 Tselect">
	<form role="form">
		     <select name="sortT" class="option">
				<option value="new" >默认</option>
				<option value="shareTime" >分享时间</option>
				<option value="size" >资源大小</option>
				<option value="doctype" >资源类型</option>
			</select>
		<button type="submit" class="btn btn-default">排序</button>
	</form>
</section>
<section class="col-xs-3 Tsearch">
	<form role="form">
		<input type="text" name="kw" placeholder="新浪微盘资源搜索" value="{$Think.get.kw}"/>    
		<button type="submit" class="btn btn-default">搜索</button>
	</form>
</section>
<table class="table table-hover table-responsive">
   <thead>
      <tr>
         <th>资源名称</th>
         <th>类型设置</th>
         <th>分享密码</th>
         <th>资源类型</th>
         <th>资源大小</th>
         <th>分享时间</th>
         <th>收录时间</th>
         <th>资源操作</th>
      </tr>
   </thead>
   <tbody>
   	<volist name="data" id="data">
      <tr class="tr_{$data.id}">
          <td>{$data.name}</td>
          <td data-id="{$data.id}">
          	<if condition="$data.type eq ''">
          		<span class="source_red source_common source_id{$data.id}">待分类</span> 
          	<else/>
          		<span class="source_green source_common source_id{$data.id}">{$data.type|strtoupper}</span> 
          	</if>
          	<span data-type="VIDEO" class="source_type">影视</span>
          	<span data-type="MUSIC" class="source_type">音乐</span>
          	<span data-type="CARTOON" class="source_type">动漫</span>
          	<span data-type="EDU" class="source_type">教育</span>
          	<span data-type="COURSE" class="source_type">教程</span>
          	<span data-type="SOFT" class="source_type">软件</span>
          	<span data-type="GAME" class="source_type">游戏</span>
          	<span data-type="BOOK" class="source_type">电子书</span>
          	<span data-type="IT" class="source_type">IT资料</span>
          	<span data-type="OTHER" class="source_type">综合其他</span>
          </td>
          <td>{$data.pwd}</td>
          <td>{$data.doctype}</td>
          <td>{$data.size}</td>
          <td>{$data.share_time|date="Y-m-d H:i:s",###}</td>
          <td>{$data.time|date="Y-m-d H:i:s",###}</td>
          <td>
          	<a href="javascript:void(0);" data-id="{$data.id}" class="source_delete">Del</a>
          </td>
      </tr>
     </volist>
   </tbody>
</table>
{$page}

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-body">
         <form role="form" id="collect_form" method="post" action="{:U('Ivdisk/json')}">
  			<div class="form-group">
    			<label for="content">新浪微盘资源收录</label>
    			<textarea id="content" name="content" class="form-control" rows="10" placeholder='你懂的方式'></textarea>
    			<!--<span class="help-block">请输入新浪微盘json数据</span>-->
  			</div>
		</form>
         </div>
         
         <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" id="collect" class="btn btn-primary">马上采集收录</button>
         </div>
      </div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>


<!-- 新浪微盘发帖模态框（Modal） -->
<div class="modal fade" id="postIvdisk" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-body">
         <form role="form" id="postIvdisk_form" method="post" action="{:U('Ivdisk/postIvdisk')}">
  			<div class="form-group">
    			<label for="content">新浪微盘发帖</label>
    				<!--<div class="form-group">-->
					      <input type="hidden" class="form-control" name="fid" value="40" readonly="readonly" placeholder="请输入fid">
					   <!--</div>-->
					   <div class="form-group">
					   	 <label for="num">发帖数量</label>
					      <input type="text" class="form-control" name="num" value="100" placeholder="发帖数量">
					   </div>
					   <div class="form-group">
					      <label for="typeid">选择资源分类[typeid]</label>
					      <select class="form-control" name="typeid" id="typeid">
					         <option value="0">--请选择资源分类--</option>
					          	<option value="9">影视</option>
					          	<option value="11">音乐</option>
					          	<option value="10">动漫</option>
					          	<option value="99">教育</option>
					          	<option value="13">教程</option>
					          	<option value="100">软件</option>
					          	<option value="12">游戏</option>
					          	<option value="15">电子书</option>
					          	<option value="14">IT资料</option>
					          	<option value="16">综合其他</option>
					      </select>
					   </div>
  			</div>
		</form>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" id="post4Ivdisk" class="btn btn-primary">马上发帖</button>
         </div>
      </div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>


</div>
<script>
   $(function () {$("[data-toggle='tooltip']").tooltip(); });
   $(document).ready(function(){
   	//默认选项
   		var sortT="{$Think.get.sortT}";
   		$option=$('.option option');
   		$.each($option, function() {    
   			if($(this).val() ==sortT){
   				$(this).attr('selected','selected');
   			}
   		});
   		
   		
	   $("#collect").click(function(){
		   if($("#content").val()==''){
			   alert('内容不能为空');
			   return false;
		   }else{
			   $("#collect_form").submit(); 
		   }
	   });
	   
	   $("#post4Ivdisk").click(function(){
		   if($("#typeid").val()==0){
			   alert('请选择资源分类');
			   return false;
		   }else{
			   $("#postIvdisk_form").submit(); 
		   }
	   });
	   
	   $('.source_type').click(function(){
	   		var _this=$(this);
	   		var type=_this.attr('data-type');
	   		var id=_this.parent().attr('data-id');
	   		$.get("{:U('Ivdisk/setType')}",{id:id,type:type},function(rt){
	   			if (rt==1) {
	   				$('.source_id'+id).text(type);
	   			}else{
	   				alert('Fail');
	   			}
	   		});
	   });
	   
	   //删除达人
	   $(".source_delete").click(function(){
			if(confirm('您确定要删除该资源?')){
				var id=$(this).attr('data-id');
				$.get("{:U('Ivdisk/del')}",{id:id},function(rt){
					if (rt==1) {
						$('.tr_'+id).remove();
					} else{
						alert('Fail');
					}
				});
			};
	   });
   });
</script>








